package com.zecan.blog.controller;

import com.zecan.blog.common.BlogResult;
import com.zecan.blog.utils.BlogResultUtils;
import com.zecan.blog.utils.RedisUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @ClassName WebSocketController
 * @Description
 * @date 2022/11/25 10:43
 * @Version 1.0
 */

@RestController
@RequestMapping("/websocket")
public class WebSocketController {

    @Resource
   private  RedisUtils redisUtils;

    /**
     * 获取聊天记录
     * @return 聊天记录
     */
    @PreAuthorize("hasAuthority('user') OR hasAuthority('admin')")
    @RequestMapping(value = "/record",method = RequestMethod.GET)
    public BlogResult getChatRoomRecord(){
        return BlogResultUtils.ok(redisUtils.getChatRoomEvent(),"获取聊天记录成功");
    }

}
